package com.hjqjl.whdemo.feature.feature0.ui.activity.list.recyclerview.model;

import com.hjqjl.whdemo.R;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class FruitModel {

    private String name;
    private int imageId;

    public FruitModel(String name, int imageId) {
        this.name = name;
        this.imageId = imageId;

    }

    public String getName() {
        return name;
    }

    public int getImageId() {
        return imageId;
    }


    /**
     * 初始化数据
     */
    public static List<FruitModel> getData() {
        List<FruitModel> fruitModelList = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            FruitModel apple = new FruitModel(getRandomLengthName("Apple"), R.drawable.ic_image_default);
            fruitModelList.add(apple);
            FruitModel banana = new FruitModel(getRandomLengthName("Banana"), R.drawable.ic_image_default);
            fruitModelList.add(banana);
            FruitModel orange = new FruitModel(getRandomLengthName("Orange"), R.drawable.ic_image_default);
            fruitModelList.add(orange);
            FruitModel watermelon = new FruitModel(getRandomLengthName("Watermelon"), R.drawable.ic_image_default);
            fruitModelList.add(watermelon);
            FruitModel pear = new FruitModel(getRandomLengthName("Pear"), R.drawable.ic_image_default);
            fruitModelList.add(pear);
            FruitModel grape = new FruitModel("Grape", R.drawable.ic_image_default);
            fruitModelList.add(grape);
            FruitModel pineapple = new FruitModel("Pineapple", R.drawable.ic_image_default);
            fruitModelList.add(pineapple);
            FruitModel strawberry = new FruitModel("Strawberry", R.drawable.ic_image_default);
            fruitModelList.add(strawberry);
            FruitModel cherry = new FruitModel("Cherry", R.drawable.ic_image_default);
            fruitModelList.add(cherry);
            FruitModel mango = new FruitModel("Mango", R.drawable.ic_image_default);
            fruitModelList.add(mango);
        }
        return fruitModelList;
    }

    private static String getRandomLengthName(String name) {
        Random random = new Random();
        int length = random.nextInt(20) + 1;  // 产生1-20的随机数
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < length; i++) {
            builder.append(name);
        }
        return builder.toString();
    }
}
